<?php

class DisplayUIInv {

    public function displayInv($array) {

		echo "<h2>View</h2>";

        echo "<table><thead><th>Name</th><th>Qty</th></thead>";

        while($row = mysql_fetch_array($array))
        {
            //echo "<tr><td>" . $row['item_id'] . "</td><td>" . $row['item_name'] . " </td><td> " . $row['item_qty'] . "</tr>";
            echo "<tr><td>" . $row['item_name'] . " </td><td> " . $row['item_qty'] . "</tr>";
        }

        echo "</table>";
    }

    public function displayAddItemForm() {
	
		echo "<h2>Add Item</h2>";
        echo  "<form method=\"post\" action=\"?section=inventory&action=submit\">"
            . "<label for=\"item_name\">Item Name:</label>"
            . "<input type=\"text\" name=\"item_name\" id=\"item_name\" /><br />"
            . "<label for=\"item_qty\">Qty:</label>"
            . "<input type=\"text\" name=\"item_qty\" id=\"item_qty\" /><br />"
            . "<input type=\"submit\"  value=\"Add\" />"
            . "<input type=\"reset\" value=\"Reset\" />"
            . "</form>";
    }
	
	public function displayEditInv($array,$mod) {
		echo "<h2>Edit " . $mod . "</h2>";
		
		echo  "<form method=\"post\" action=\"?section=inventory&action=edit\">"
            . "<label for=\"item_id\">Item Name:</label>"			
			. "<select id=\"item_id\" name=\"item_id\">";
			
		while($row = mysql_fetch_array($array))
		{				
			echo "<option value=\"" . $row['item_id'] . "\">" . $row['item_name'] . " </option>\n";
		}
		echo  "</select><br />";

		if( $mod == "name" ) {
			echo  "<label for=\"item_name\">New Name:</label>"
            	. "<input type=\"text\" name=\"item_name\" id=\"item_name\" /><br />";
		}
		else {
			echo  "<label for=\"item_qty\">New Qty:</label>"
				. "<input type=\"text\" name=\"item_qty\" id=\"item_qty\" /><br />";
		}
		
		echo  "<input type=\"submit\"  value=\"Edit\" />"
			. "<input type=\"reset\" value=\"Reset\" />"
			. "</form>";
    }
	
	public function displayDeletionInv($array) {

     	echo "<h2>Delete</h2>";
		
		echo  "<form method=\"post\" action=\"?section=inventory&action=delete\">"
            . "<label for=\"item_id\">Item Name:</label>"			
			. "<select id=\"item_id\" name=\"item_id\">";
			
			
		while($row = mysql_fetch_array($array))
		{				
			echo "<option value=\"" . $row['item_id'] . "\">" . $row['item_name'] . " </option>\n";
		}
		echo  "</select><br />";
		
		echo  "<input type=\"submit\"  value=\"Delete\" />"
			. "<input type=\"reset\" value=\"Reset\" />"
			. "</form>";
		
    }
}

?>
